home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / CIncludes / strstream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-05  |  2.3 KB  |  110 lines  |  [TEXT/MPS ]

  1. /*
  2.     strstream.h -- Streams classes: strstreambuf, strstreambase, istrstream, ostrstream, strstream
  3.  
  4.     Copyright Apple Computer,Inc.    1994-1995
  5.     All rights reserved.
  6.  
  7. */
  8.  
  9. #ifndef __STRSTREAM__
  10. #define __STRSTREAM__      1
  11.  
  12. #include <iostream.h>
  13.  
  14. #ifdef powerc
  15. #pragma options align=power
  16. #endif
  17.  
  18. class strstreambuf : public streambuf
  19. {
  20.  
  21. public:
  22.                 strstreambuf();
  23.                 strstreambuf(int);
  24.                 strstreambuf(void* (*a)(long), void (*f)(void*));
  25.                 strstreambuf(char* b, int size, char* pstart = 0);
  26.                 strstreambuf(unsigned char* b, int size, unsigned char* pstart = 0);
  27.                 ~strstreambuf();
  28.     int         pcount();
  29.     void        freeze(int n = 1);
  30.     char*       str();
  31.  
  32. public:
  33.     virtual int         doallocate();
  34.     virtual int         overflow(int);
  35.     virtual int         underflow();
  36.     virtual streambuf*  setbuf(char* p, int l);
  37.     virtual streampos   seekoff(streamoff, ios::seek_dir, int);
  38.  
  39. private:
  40.     void        init(char*, int, char*);
  41.     void*       (*afct)(long);
  42.     void        (*ffct)(void*);
  43.     int         ignore_oflow;
  44.     int         froozen;
  45.     int         auto_extend;
  46.  
  47. public:
  48.     int         isfrozen()              { return froozen; }
  49.  
  50. };  // class strstreambuf
  51.  
  52.  
  53. class strstreambase : public virtual ios
  54. {
  55.  
  56. public:
  57.                 strstreambuf* rdbuf();
  58.  
  59. protected:
  60.                 strstreambase(char*, int, char*);
  61.                 strstreambase();
  62.                 ~strstreambase();
  63.  
  64. private:
  65.     strstreambuf buf;
  66.  
  67. };  // class strstreambase
  68.  
  69.  
  70. class istrstream : public strstreambase, public istream
  71. {
  72.  
  73. public:
  74.                 istrstream(char* str);
  75.                 istrstream(char* str, int size);
  76.                 ~istrstream();
  77.  
  78. };  // class istrstream
  79.  
  80.  
  81. class ostrstream : public strstreambase, public ostream
  82. {
  83.  
  84. public:
  85.                 ostrstream(char* str, int size, int mode = ios::out);
  86.                 ostrstream();
  87.                 ~ostrstream();
  88.     char*       str();
  89.     int         pcount();
  90.  
  91. };  // class ostrstream
  92.  
  93.  
  94. class strstream : public strstreambase, public iostream
  95. {
  96.  
  97. public:
  98.                 strstream();
  99.                 strstream(char* str, int size, int mode);
  100.                 ~strstream();
  101.     char*       str();
  102.  
  103. };  // class strstream
  104.  
  105. #ifdef powerc
  106. #pragma options align=reset
  107. #endif
  108.  
  109. #endif    /* __STRSTREAM__ */
  110.